<template>
  <div class='questions-check'>
    <el-radio-group class="selectRadio" v-model="checkForm.checkStatus">
      <el-radio label="1">通过</el-radio>
      <el-radio label="2">拒绝</el-radio>
    </el-radio-group>
    <el-input
          type="textarea"
          :rows="2"
          placeholder="请输入审核意见"
          v-model="checkForm.CheckOpinion">
    </el-input>
    <div style="text-align: right; margin-top: 40px;" >
      <el-button @click="$emit('closeDialog')">取 消</el-button>
      <el-button type="primary" @click="getQuestionsCheck">确 定</el-button>
    </div>
  </div>
</template>
<script>
// 导入试题审核数据接口
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'QuestionsCheck',
  props: {
    questionCheckDate: {
      type: [Number, String, Object],
      required: true
    }
  },
  data () {
    return {
      checkForm: {
        // 审核状态--默认值为1
        checkStatus: '1',
        // 审核意见
        CheckOpinion: ''
      },
    }
  },
  methods: {
    // 试题审核功能的实现
    async getQuestionsCheck () {
      // 判断审核意见是否为空，为空则警告提示
      if (this.checkForm.CheckOpinion.length === 0) return this.$message.warning('请输入审核意见！')
      // 试题审核请求
      try {
        // 试题审核当前项id值
        const id = this.questionCheckDate.id
        await choiceCheck({
          id: id,
          chkState: this.checkForm.checkStatus - 0,
          chkRemarks: this.checkForm.CheckOpinion
        })
        this.$message.success('审核成功！')
      } catch (err) {
        this.$message.error('当前数据信息有误，请稍后重试！')
      }
      // 关闭审核试题弹出框
      this.$emit('closeDialog')
      // 当前列表刷新
      this.$emit('updateList')
    }
  }

}
</script>

<style scoped lang='less'>
.selectRadio {
  margin-bottom: 30px;
}
</style>
